<div id="tab-system" class="HuiTab">
	<div class="tabBar cl">
		<span class="current">文章列表</span>
		<span onclick="list_add()">添加文章</span>
	</div>
	<br>
</div>
<div>
  <form action="${BASE}/admin/cms/article/list" id="form_pager_search" method="post">
    <input type="hidden" name="_p_pageNumber" value="${pager.pageNumber}">
    <input type="hidden" name="_p_pageSize" value="${pager.pageSize}">
    <%
      var colId = 0;
	  if(isNotEmpty(searchKeys.columnId)){
		colId = parseInt(searchKeys.columnId);
	  }
	%>
	<select class="select" id="_s_columnId" name="_s_columnId" style="width:150px;" onchange="list_search()">
		<option value="0">所有栏目</option>
	<% for(column in columnlist){ %>
		<option value="${column.id}" ${column.id==colId?"selected"}>${column.name}</option>
		<% for(child in column.childList){ %>
			<option value="${child.id}" ${child.id==colId?"selected"}>├ ${child.name}</option>
		<% } %>
	<% } %>
	</select>
	<input type="text" class="input-text" style="width:150px" placeholder="文章标题" id="_s_title" name="_s_title" value="${searchKeys.title!}">
	<button type="button" class="btn btn-success" onclick="list_search()"><i class="Hui-iconfont">&#xe665;</i> 查找</button>
  </form>
</div>
<form action="${BASE}/admin/cms/article/updateSort" id="form_updateSort" method="post">
<div class="cl pd-5 bg-1 bk-gray mt-20"> 
	<span class="l">
		<a href="javascript:;" onclick="list_del()" class="btn btn-danger size-S radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>
		<a href="javascript:;" class="btn btn-primary size-S radius btn_submit"><i class="Hui-iconfont">&#xe6e2;</i> 保存排序</a>
	</span>
	<span class="r"><select class="select" onchange="list_changeSize(this.value)">
			<option value="10" ${pager.pageSize==10?"selected":""}>10</option>
			<option value="20" ${pager.pageSize==20?"selected":""}>20</option>
			<option value="50" ${pager.pageSize==50?"selected":""}>50</option>
			<option value="100" ${pager.pageSize==100?"selected":""}>100</option>
		</select>
	</span>
</div>
<div class="dataTables_wrapper no-footer">
<table class="table table-border table-bordered table-bg table-striped table-hover">
	<thead>
		<tr class="text-c"><th width="25"><input type="checkbox" name="" value=""></th><th width="40">ID</th>
	<th>标题</th>
	<th width="100">排序</th>
	<th width="150">栏目</th>
	<th width="90">点击数</th><th width="110">操作</th></tr>
	</thead>
	<tbody>
	<% for(obj in pager.list){ %>
		<tr class="text-c"><td><input type="checkbox" value="${obj.id}" name="table_checkbox_id"></td>
			<td>${obj.id}</td>
			<td>${obj.title}</td>
			<td>
			  <input type="hidden" name="ids" value="${obj.id}"/>
			  <input name="sorts" type="text" class="input-text text-c" value="${obj.sort}" datatype="n"></td>
			<td>${obj.colName}</td>
			<td>${obj.hits}</td>
			<td class="td-manage">
				<a class="btn btn-secondary size-MINI" href="javascript:;" title="编辑" onclick="list_edit('${obj.id}')"><i class="Hui-iconfont">&#xe6df;</i> 编辑</a> 
				<a class="btn btn-danger size-MINI" href="javascript:;" title="删除" onclick="list_del('${obj.id}')"><i class="Hui-iconfont">&#xe6e2;</i> 删除</a>
			</td>
		</tr>
	<% } %></tbody>
</table>
<%include("/inc/pagging.html",{'pageNumber':pager.pageNumber,'pageCount':pager.pageCount,'recordCount':pager.recordCount}){}%>
</div>
</form>
<script type="text/javascript">
function list_del(id){
	var select_ids = "";
	if(id){
		select_ids=id;
	}else{
	    $("input[name='table_checkbox_id']:checked").each(function(){
	    	select_ids+=$(this).val()+",";   
	    });
	    if(""==select_ids){
	    	layer.msg('请先选择要删除的数据！', {icon: 3,offset: '45px'});
	    	return false;
	    }
	}
	layer.confirm('确认删除所选记录?', {icon: 3, title:'警告'}, function(index){	    
	    layer.close(index);
	    HtmlRender("${BASE}/admin/cms/article/del",{ids:select_ids});
	});
}
function list_add(){
	var params = "";
	if(isExitsFunction("getAddParams"))
		params = getAddParams();
	HtmlRender('${BASE}/admin/cms/article/add'+params);
}
function list_edit(id,state){
    HtmlRender("${BASE}/admin/cms/article/edit",{id:id});
}
function list_search(){
	var $form = $("#form_pager_search");
	var url = $form.attr('action');
	var $input  = $("<input type='hidden' name='_sbtn' value='true' />");
	$form.append($input);
    HtmlRender(url,$form.serializeArray());
}
function list_changeSize(size){
	$("#form_pager_search > [name='_p_pageSize']").val(size);
	var $form = $("#form_pager_search");
	var url = $form.attr('action');
	var $input  = $("<input type='hidden' name='_sbtn' value='true' />");
	$form.append($input);
    HtmlRender(url,$form.serializeArray());
}
function getAddParams(){
	var vv = $("#_s_columnId").val();
	return "?columnId="+vv;
}
$(function(){
	$("#form_updateSort").Validform({
		btnSubmit:".btn_submit",
		ajaxPost:true,
		postonce:true,
		callback:function(data){
			$.Hidemsg();
			if("200"==data.retCode){
				layer.msg('保存成功！', {icon: 6,offset: '45px'});
			}else{
				layer.msg(data.retMsg, {icon: 5,offset: '45px'});
			}
		}
	});
});
</script>